import 'package:flutter/material.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/data/entities/home/analysis/get_risk_entity.dart';
///风险统计详情弹窗
class StatisticalDialog extends StatefulWidget {
  const StatisticalDialog({required this.title,required this.data, super.key, });

  final String title;
  final List<GetRiskEntity> data;



  @override
  State<StatisticalDialog> createState() => _StatisticalDialogState();
}

class _StatisticalDialogState extends State<StatisticalDialog> {




  @override
  void initState() {
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
        left: 20.w,
        right: 20.w,
        top: 90.w,
        bottom: 60.w,
      ),
      padding: EdgeInsets.all(20.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(widget.title,style: TextStyle(fontSize: 18.w,fontWeight: FontWeight.w500,color: const Color(0xff1D3452)),),
              IconButton(onPressed: Get.back, icon: const Icon(Icons.close)),
            ],
          ),
          SizedBox(height: 20.w,),
          Row(
            children: [
              Expanded(child: Text('风险点',textAlign: TextAlign.center,style: TextStyle(fontSize: 16.sp,color: const Color(0xffC7CEE5)),)),
              AppGaps.hGap2,
              Expanded(child: Text('风险名称',textAlign: TextAlign.center,style: TextStyle(fontSize: 16.sp,color: const Color(0xffC7CEE5)),)),
              AppGaps.hGap2,
              Expanded(child: Text('责任部门',textAlign: TextAlign.center,style: TextStyle(fontSize: 16.sp,color: const Color(0xffC7CEE5)),)),
            ],
          ),
          const Divider(color: Color(0xffEEF0F7),),
           Expanded(child:  widget.data.isNotEmpty? ListView.separated(
            itemCount: widget.data.length,
            itemBuilder: (context, index) {
              return Row(
                children: [
                  Expanded(
                      child: Text(
                        '${ widget.data[index].riskName}',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 15.sp, color: const Color(0xff3D4769)),
                      )),
                  AppGaps.hGap2,
                  Expanded(
                      child: Text(
                        '${ widget.data[index].dangerName}',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 15.sp, color: const Color(0xff3D4769)),
                      )),
                  AppGaps.hGap2,
                  Expanded(
                      child: Text(
                        '${ widget.data[index].responsibleDepts}',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 15.sp, color: const Color(0xff3D4769)),
                      )),
                ],
              );
            },
            separatorBuilder: (context, index) => const Divider(color: Color(0xffEEF0F7),),
          ):Center(
            child: Text('暂无相关数据',style: TextStyle(fontSize: 16.w,color: const Color(0xff3D4769)),),
    ))
        ],
      ),
    );
  }
}
